package com.wanji.protocol.api;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public abstract class DeviceMessageDecoder<T> extends SimpleChannelInboundHandler<T> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, T in) {
        DeviceMessage message = toDeviceMessage(ctx, in);
        ctx.fireChannelRead(message);
    }

    protected abstract DeviceMessage toDeviceMessage(ChannelHandlerContext ctx, T in);
}
